#include <bits/stdc++.h>
using namespace std;
/*
 * @lc app=leetcode.cn id=1 lang=cpp
 *
 * [1] 两数之和
 */

// @lc code=start
class Solution {
public:
    vector<int> twoSum(vector<int>& nums, int target) {
        unordered_map<int, int> mapper;
        vector<int> res;
        for (int i = 0; i < nums.size(); i++) mapper.insert({nums[i], i});
        for (int i = 0; i < nums.size(); i++) {
            if (mapper.count(target - nums[i]) > 0 && mapper[target - nums[i]] != i) {
                res.push_back(i); res.push_back(mapper[target - nums[i]]);
                break;
            }
        }
        return res;
        
    }
};
// @lc code=end

